<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list"
    style="padding: 20px 30px 0 0;">

    <script type='text/html' template lay-done='layui.data.formdone(d.params);'>
        <input type='hidden' name='PID' id='PID' value="{{ d.params.PID || '' }}"/>
    </script>

    <div class='layui-form-item'>
        <label class='layui-form-label'>会员手机号 </label>
        <div class='layui-input-block'>
            <div class="layui-input-inline">
                <input type="text" name="key" id="key" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <input type="button" id="submit" lay-filter="layuiadmin-app-form-submit" value="确认" class="layui-btn">
        </div>
    </div>

</div>


<script type="text/javascript">

    layui.use(['form', 'admin', 'upload', 'laydate', 'formSelects'], function () {

        var form = layui.form;//required（必填项）phone（手机号）email（邮箱）url（网址）number（数字）date（日期）identity（身份证） 自定义值
        var formSelects = layui.formSelects;
        var admin = layui.admin;
        var $ = layui.$;



        $("#submit").click(function () {
            var couponId = $("#PID").val();
            var key = $("#key").val();

            if (!couponId) {
                return layer.msg("请选择优惠券");
            }
            debugger
            layer.load(); //上传loading
            admin.req({
                url: layui.setter.APIUrl + '/shop/CouponMgr/sendCouponByName', //实际使用请改成服务端真实接口
                type: 'post',
                data: { couponId: couponId, phone: key },
                done: function (res) {
                    layer.closeAll('loading'); //关闭loading
                    layer.closeAll();
                    layer.msg(res.ResultInfo);
                    //table.reload('LAY-app-content-list');
                },
                error: function (res) {
                    debugger
                    layer.closeAll('loading'); //关闭loading
                }
            });
        });

    });


    layui.data.formdone = function (d) {
        var $ = layui.$;
        var admin = layui.admin;
        var form = layui.form;

    }


</script>